package com.作业.Day10;

import java.util.Scanner;

public class Homework4 {
    static boolean login;
    public static void main(String[] args) {

            while (true){
                service service = new service();
                service.show();
                Scanner scanner = new Scanner(System.in);
                int next = scanner.nextInt();
                int extracted = service.extracted(next);
                Customer customer = new Customer();
                System.out.println("请输入个人注册信息");
                if(extracted==1){
                    login=false;
                    String userName = scanner.next();
                    String passWord=scanner.next();
                    customer.setUserName(userName);
                    customer.setPassWord(passWord);
                    boolean register1 = service.register(customer);
                    service.isRegister(register1, userName, passWord, service);
                }
                else if(extracted==2){
                    for (int i = 0; i <3 ; i++) {
                        System.out.print("请输入用户名:");
                        String userName = scanner.next();
                        System.out.print("请输入密码:");
                        String passWord = scanner.next();
                        customer.setUserName(userName);
                        customer.setPassWord(passWord);
                        login = service.login(customer);

                        if(!login){
                            System.out.println("您还有"+i+"次机会");
                        }
                        else {
                            System.out.println("欢迎你"+customer.getUserName());
                            break;
                        }
                    }
                }
                  if(extracted==3){
                    if(login){
                        System.out.println("请输入您的卡号");
                        customer.setCard(scanner.next());
                        int a = service.ramDom();
                        int b = service.ramDom();
                        int c = service.ramDom();
                        System.out.println("本日的幸运数字为"+a+","+b+","+c);
                        if(customer.getCard().equals(a)){
                            System.out.println("您是幸运会员");
                        }
                        else
                            System.out.println("您不是幸运会员");
                    }
                     else
                        System.out.println("您没有登录，请重新登录");

                }
                System.out.println("继续吗?(y/n)");
                String next1 = scanner.next();
                if(next1=="y")
                    continue;
                else if(next1=="n")
                    break;
            }




    }


}
